#ifndef FAST_STRING_TABLE_H
#define FAST_STRING_TABLE_H

#include "lexic_unit.h"
#include "generic_table.h"
#include "generic_table.cpp"
#include "string.h"

class LexicUnitWithString {
public:	
	LexicUnitWithString(int id, char *str)	{
		this->id = id;
		name = new char[strlen(str) + 1];
		strcpy(name, str);
	}

	~LexicUnitWithString()	{
		if(name != NULL)	{
			delete[] name;
			name = NULL;
		}
	}

	int id;
	char *name;

	//void ChangeNameTo(char *str)	{
	//	if(name != NULL)	delete[] name;
	//	name = new char[strlen(str) + 1];
	//	strcpy(name, str);
	//}
};


class FastStringTable {
private:
	GenericTable<LexicUnitWithString> *table;

public:
	FastStringTable()	{
		table = new GenericTable<LexicUnitWithString>();
	}

	~FastStringTable()	{
		delete table;
	}

	LexicUnitWithString *GetUnit(int id);
	LexicUnitWithString *GetUnit(char *str);
	LexicUnitWithString *GetUnitAt(int index);
	
	bool RemoveAt(int index);
	int Add(char *str);
	int GetCount();
};

#endif
